package com.wyhello.tube4.spring.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


import com.wyhello.tube4.pojo.Dictionary;
import com.wyhello.tube4.spring.model.DictionaryRecordsModel;
@Controller
public class DictionaryController {
	@Autowired
	private DictionaryRecordsModel dictionaryRecordsModel;
	@RequestMapping("/dictionary/saveDictionary")
	public String saveDictionary(Dictionary dictionary){
		dictionaryRecordsModel.saveDictionary(dictionary);
		return "success";
	}
	@RequestMapping("/dictionary/queryDictionary")
	public ModelAndView queryDictionary(){
		List<Dictionary> dictionarys = dictionaryRecordsModel.queryDictionary();
		ModelAndView model = new ModelAndView("list","dictionarys",dictionarys);
		return model;
	}
	@RequestMapping("/dictionary/deleteDictionary")
	public String deleteDictionary(HttpServletRequest request){
		String ids = request.getParameter("deletid");
		dictionaryRecordsModel.deleteDictionarys("("+ids+")");
		return "success";
	}
}
